home *** CD-ROM | disk | FTP | other *** search
- section d,code_c
-
- include macro
- hs = $dff000
- disable = -$78
- enable = -$7e
- forbid = -$84
- permit = -$8a
- openlib = -$228
- closelib = -$19e
- allocmem = -198
- freemem = -210
- dl_width = 40
- dl_fill = 1 ;0: nofill 1:fill
- col0 = $180
- col1 = $182
- col2 = $184
- col3 = $186
- col4 = $188
- col5 = $18a
- col6 = $18c
- col7 = $18e
- col8 = $190
- col9 = $192
- col10 = $194
- col11 = $196
- col12 = $198
- col13 = $19a
- col14 = $19c
- col15 = $19e
- col16 = $1a0
- col17 = $1a2
- col18 = $1a4
- col19 = $1a6
- col20 = $1a8
- col21 = $1aa
- col22 = $1ac
- col23 = $1ae
- col24 = $1b0
- col25 = $1b2
- col26 = $1b4
- col27 = $1b6
- col28 = $1b8
- col29 = $1ba
- col30 = $1bc
- col31 = $1be
- col32 = $1c0
-
-
-
- run:
- move.l #$2800*4,d0
- move.l #$10003,d1
- move.l $4.w,a6
- jsr allocmem(a6)
- move.l d0,screen
-
- move.l #$2800*4,d0
- move.l #$10003,d1
- move.l $4.w,a6
- jsr allocmem(a6)
- move.l d0,screen+4
-
- move.l #$3980,d0
- move.l #$10003,d1
- move.l $4.w,a6
- jsr allocmem(a6)
- move.l d0,pl_menu
-
- ;code-out ***********************
- lea gfxname,a1
- move.l $4.w,a6
- jsr openlib(a6)
- move.l d0,a1
- move.l 38(a1),pcop
- jsr closelib(a6)
- move.l $6c.w,pint
- ;code-in ***********************
- bsr.w confp
-
- move.l $4.w,a6
- jsr disable(a6)
- move.l #cint,$6c.w
- move.l #ccop,hs+cop1lch
- move.w hs+dmaconr,s_1
- move.w hs+intenar,s_1+2
- move.w #$7fff,hs+dmacon
- move.w #$7fff,hs+intena
- move.w #%1000011111001111,hs+dmacon
-
- move.w #%1100000000010000,hs+intena
- bset #1,$bfe001
-
- move.l #pl_logo,d0
- move.w d0,cp_plns+30
- swap d0
- move.w d0,cp_plns+26
-
- move.l pl_menu,d0
- move.w d0,cp_plns2+6
- swap d0
- move.w d0,cp_plns2+2
-
- ;-----------------
- main: cmp.b #$ff,$dff006
- bne.s rv
- bsr vbli
- rv: btst #6,$bfe001
- bne.b main
- exit:
- ;code-out ***********************
- move.l pcop,hs+cop1lch
- move.l pint,$6c.w
- move.w s_1,d0
- move.w s_1+2,d1
- bset #15,d0
- bset #15,d1
- move.w #$7fff,hs+dmacon
- move.w #$7fff,hs+intena
- move.w d0,hs+dmacon
- move.w d1,hs+intena
- move.l $4.w,a6
- jsr enable(a6)
- ;code-in ***********************
- move.l #$2800*4,d0
- move.l screen,a1
- move.l $4.w,a6
- jsr freemem(a6)
- move.l #$2800*4,d0
- move.l screen+4,a1
- move.l $4.w,a6
- jsr freemem(a6)
- move.l #$3980,d0
- move.l pl_menu,a1
- move.l $4.w,a6
- jsr freemem(a6)
-
- moveq.l #0,d0
- rts
- ;----------------
-
- vbli: tst.b menu_on
- bne menu_run
- cmp.b #$6d,cp_bd1
- bgt menu_off
- beq menu_setoff
- add.b #4,cp_bd1
- menu_run:
- bsr.w confp
- bsr.w cls
- bsr vc_rcen
- bsr.w vc_rotate
- bsr.w vc_fclk
- bsr.w vc_dr
- bsr.w vc_anh
- bra menu_bypass
- menu_setoff:
- move.l #ccop2,cop1lch+hs
- bsr confp2
- bsr cls2
- move.b #$71,cp_bd1
- at_wb: btst #14,dmaconr+hs
- bne at_wb
-
- bra menu_bypass
- menu_off:
-
- menu_bypass:
- rts
- ;----------------
- cint: movem.l d0-d7/a0-a6,-(sp)
- btst #4,hs+intreqr ;verify int_source
- beq.b eint
- move.w #$10,hs+intreq ;clear int_bit
-
- eint: movem.l (sp)+,d0-d7/a0-a6
- dc.w $4ef9
- pint: dc.l 0
- ;---------------
-
- confp: ;Configure planes *********************
- move.l screen,d0
- move.w d0,cp_plns+6
- swap d0
- move.w d0,cp_plns+2
- swap d0
- add.l #$2800,d0
- move.w d0,cp_plns+14
- swap d0
- move.w d0,cp_plns+10
- swap d0
- add.l #$2800,d0
- move.w d0,cp_plns+22
- swap d0
- move.w d0,cp_plns+18
- move.l screen+4,d0
- move.l screen,screen+4
- move.l d0,screen
- rts
-
- confp2: ;Configure planes *********************
- move.l screen,d0
- move.w d0,cp2_plns+6
- swap d0
- move.w d0,cp2_plns+2
- swap d0
- add.l #$2800,d0
- move.w d0,cp2_plns+14
- swap d0
- move.w d0,cp2_plns+10
- swap d0
- add.l #$2800,d0
- move.w d0,cp2_plns+22
- swap d0
- move.w d0,cp2_plns+18
- swap d0
- add.l #$2800,d0
- move.w d0,cp2_plns+30
- swap d0
- move.w d0,cp2_plns+26
- rts
-
- cls: btst #14,hs+dmaconr
- bne.b cls
- move.l screen,hs+bltdpth
- clr.w hs+bltdmod
- clr.w hs+bltafwm
- clr.w hs+bltalwm
- move.w #$100,hs+bltcon0
- clr.w hs+bltcon1
- move.w #$c014,hs+bltsize
- rts
-
- cls2: btst #14,hs+dmaconr
- bne.b cls2
- move.l screen,hs+bltdpth
- clr.w hs+bltdmod
- clr.w hs+bltafwm
- clr.w hs+bltalwm
- move.w #$100,hs+bltcon0
- clr.w hs+bltcon1
- move.w #$8014,hs+bltsize
- rts
-
- vc_anh: add.w #2,xtheta
- cmp.w #361,xtheta
- bne.b vc_xok
- move.w #1,xtheta
- vc_xok: add.w #2,ytheta
- cmp.w #361,ytheta
- bne.b vc_yok
- move.w #1,ytheta
- vc_yok: add.w #2,ztheta
- cmp.w #361,ztheta
- bne.b vc_zok
- move.w #1,ztheta
- vc_zok: rts
-
- vc_rcen:
- lea vc_ca,a1
- lea vc_cr,a2
- lea sintable,a0
- move.w vc_faces,d5
- vc_rr:
- move.w ztheta,d6
- lsl.w #2,d6
- move.w (a0,d6),d0 ;d0 contains sin (theta)
- move.w 2(a0,d6),d1 ;d1 contains cos (theta)
- move.w d0,d2
- move.w d1,d3 ;copies d0-d1 into d2-d3
- muls (a1),d0 ;d0 contains x*sin (theta)
- muls (a1),d1 ;d1 contains x*cos (theta)
- muls 2(a1),d2 ;d2 contains y*sin (theta)
- muls 2(a1),d3 ;d3 contains y*cos (theta)
- move.w 4(a1),d4 ;skip z because z=z
- sub.l d2,d1 ;d1 now contains x (think about it...)
- add.l d0,d3 ;d3 now contains y
- asr.l #7,d1
- asr.l #7,d3
- asr.l #8,d1
- asr.l #8,d3
-
- move.w ytheta,d6
- lsl.w #2,d6
- move.w (a0,d6),d0 ;d0 contains sin (theta)
- move.w 2(a0,d6),d2 ;d2 contains cos (theta)
- move.w d0,d7
- move.w d2,d6 ;copies d0,d2 into d5,d6
- muls d1,d2 ;d2 contains x*cos (theta)
- muls d4,d0 ;d0 contains z*sin (theta)
- muls d4,d6 ;d6 contains z*cos (theta)
- muls d1,d7 ;d5 contains x*sin (theta)
- sub.l d0,d2 ;d2 now contains x
- add.l d6,d7 ;d7 now contains z
- asr.l #7,d2
- asr.l #7,d7
- asr.l #8,d2
- asr.l #8,d7
-
- move.w xtheta,d6
- lsl.w #2,d6
- move.w (a0,d6),d0 ;d0 contains sin (theta)
- move.w 2(a0,d6),d1 ;d1 contains cos (theta)
- move.w d0,d4
- move.w d1,d6 ;copies d0,d1 into d4,d6
- muls d7,d1 ;d1 contains z*cos (theta)
- muls d3,d0 ;d0 contains y*sin (theta)
- muls d3,d6 ;d6 contains y*cos (theta)
- muls d7,d4 ;d4 contains z*sin (theta)
- sub.l d0,d1 ;d1 now contains z
- add.l d6,d4 ;d4 now contains y
- asr.l #7,d1
- asr.l #7,d4
- asr.l #8,d1
- asr.l #8,d4
-
- move.w d1,(a2)+
- addq.w #6,a1
- dbra d5,vc_rr
- vc_sr: rts
-
- vc_rotate:
- move.l #vc_pfp+100,vc_ds+2
- lea vc_a,a4
- lea vc_pfp,a2
- lea sintable,a0
- vc_nf: move.l (a4)+,a1
- cmp.w #0,a1
- beq.w vc_srot
- move.w (a1)+,d5
- move.w vc_dst,a3
- move.w d5,(a2)+
- vc_moretorot:
- move.w ztheta,d6
- lsl.w #2,d6
- move.w (a0,d6),d0 ;d0 contains sin (theta)
- move.w 2(a0,d6),d1 ;d1 contains cos (theta)
- move.w d0,d2
- move.w d1,d3 ;copies d0-d1 into d2-d3
- muls (a1),d0 ;d0 contains x*sin (theta)
- muls (a1),d1 ;d1 contains x*cos (theta)
- muls 2(a1),d2 ;d2 contains y*sin (theta)
- muls 2(a1),d3 ;d3 contains y*cos (theta)
- move.w 4(a1),d4 ;skip z because z=z
- sub.l d2,d1 ;d1 now contains x (think about it...)
- add.l d0,d3 ;d3 now contains y
- asr.l #7,d1
- asr.l #7,d3
- asr.l #8,d1
- asr.l #8,d3
-
- move.w ytheta,d6
- lsl.w #2,d6
- move.w (a0,d6),d0 ;d0 contains sin (theta)
- move.w 2(a0,d6),d2 ;d2 contains cos (theta)
- move.w d0,d7
- move.w d2,d6 ;copies d0,d2 into d5,d6
- muls d1,d2 ;d2 contains x*cos (theta)
- muls d4,d0 ;d0 contains z*sin (theta)
- muls d4,d6 ;d6 contains z*cos (theta)
- muls d1,d7 ;d5 contains x*sin (theta)
- sub.l d0,d2 ;d2 now contains x
- add.l d6,d7 ;d7 now contains z
- asr.l #7,d2
- asr.l #7,d7
- asr.l #8,d2
- asr.l #8,d7
-
- move.w xtheta,d6
- lsl.w #2,d6
- move.w (a0,d6),d0 ;d0 contains sin (theta)
- move.w 2(a0,d6),d1 ;d1 contains cos (theta)
- move.w d0,d4
- move.w d1,d6 ;copies d0,d1 into d4,d6
- muls d7,d1 ;d1 contains z*cos (theta)
- muls d3,d0 ;d0 contains y*sin (theta)
- muls d3,d6 ;d6 contains y*cos (theta)
- muls d7,d4 ;d4 contains z*sin (theta)
- sub.l d0,d1 ;d1 now contains z
- add.l d6,d4 ;d4 now contains y
- asr.l #7,d1
- asr.l #7,d4
- asr.l #8,d1
- asr.l #8,d4
-
- asl.l #8,d2
- asl.l #8,d4
- move.w a3,d3
- add.w d1,d3
- divs d3,d2
- divs d3,d4
-
- move.w d2,(a2)+
- move.w d4,(a2)+
- addq.w #6,a1
- dbra d5,vc_moretorot
- clr.l (a2)+
- vc_ds: lea vc_pfp+100,a2
- add.w #100,vc_ds+4
- bra.w vc_nf
- vc_srot:rts
-
- vc_dr: lea $dff000,a5
- move.l #vc_pfs,vc_mr+2
- vc_mr: lea vc_pfs,a0
- move.w (a0),d0
- tst.w d0
- beq.w vc_fd
- move.l a0,a1
- move.l screen,a4
- move.w d0,d6
- mulu #40,d0
- add.w d0,a4
- move.w (a0),d1
- move.w 2(a0),d0
- move.w -4(a0),d3
- move.w -2(a0),d2
- bsr.w vc_grad
- move.l d1,vc_lx
- move.w (a1),d1
- move.w 2(a1),d0
- move.w 4(a1),d3
- move.w 6(a1),d2
- bsr.w vc_grad
- move.l d1,vc_rx
- move.l vc_lx,d0
- move.l vc_rx,d1
- moveq #0,d2
- moveq #0,d3
- move.w 2(a0),d2 ;lx
- move.w 2(a0),d3 ;rx
- vc_wb2: btst #14,dmaconr(a5)
- bne.b vc_wb2
- move.w #%11111001010,bltcon0(a5) ;alt (b source)
- clr.w bltcon1(a5)
- move.w #-1,bltadat(a5)
- ;d0=loff d1=roff d2=lcr d3=rcr d6=y
- subq #4,a0
- addq #4,a1
-
- subq.w #1,d2
- addq.w #1,d3
-
- bra.b vc_lp
- vc_blp: cmp.w (a0),d6
- bne.s vc_a1
- vc_nlfgrd: ;change left gradient
- movem.l d1-d4,-(sp)
- move.w (a0),d1
- move.w 2(a0),d0
- move.w -4(a0),d3
- move.w -2(a0),d2
- cmp.w d3,d1
- blt.b vc_ne2
- movem.l (sp)+,d1-d4
- add.w #200,vc_mr+4
- bra.w vc_mr
- vc_ne2: bsr.w vc_grad
- move.l d1,d0
- movem.l (sp)+,d1-d4
- subq #4,a0
- vc_a1: cmp.w (a1),d6
- bne.s vc_a2
- vc_nrtgrd: ;change right gradient
- movem.l d0/d2-d4,-(sp)
- move.w (a1),d1
- move.w 2(a1),d0
- move.w 4(a1),d3
- move.w 6(a1),d2
- bsr.w vc_grad
- movem.l (sp)+,d0/d2-d4
- addq #4,a1
- vc_a2: lea 40(a4),a4
- addq.b #1,d6
- vc_lp: swap d2
- swap d3
- add.l d0,d2
- add.l d1,d3
- swap d2
- swap d3
- move.w d3,d4
- sub.w d2,d4
- blt.b vc_blp
- move.w d2,d5
- lsr.w #3,d5
- lea (a4,d5),a6 ;bltdpth = a6
- lea shades,a3 ;bltbpth = a3
- lsl.w #5,d4
- lea (a3,d4),a3
- lsr.b #1,d5
- move.w d3,d4
- lsr.w #4,d4
- sub.b d5,d4
- lea 10238.w,a2
- sub.w d4,a2
- sub.w d4,a2
- add.w #$c1,d4
- move.b d2,d5
- moveq #-1,d7
- and.b #%1111,d5
- lsr.w d5,d7
- lsl.b #4,d5
- lsl.w #8,d5
- ;a bltwait really isn't necessary. (only if your stupid!)
- move.w a2,bltcmod(a5)
- move.w a2,bltdmod(a5)
- lea -$940(a2),a2
- move.w a2,bltbmod(a5)
- move.w d7,bltafwm(a5) ;d7
- move.w d5,bltcon1(a5) ;d5
- sub.w d7,d7 ;Is this faster than clr.w? I think they're
- move.b d3,d5 ;both 4 clock cycles... but why not?
- and.b #%1111,d5
- asr.l d5,d7
- move.w d7,bltalwm(a5)
- move.l a3,bltbpth(a5)
- move.l a6,bltcpth(a5)
- move.l a6,bltdpth(a5)
- move.w d4,bltsize(a5)
- bra.w vc_blp
- vc_fd: rts
-
- vc_grad:
- ;Kills:
- ;d1,d2,d3,d4,d5
- ;Returns:
- ;d3 = depth of line y1 to y2
- ;d1 = gradient in terms of y increment for each raster(x)
- sub.w d0,d2
- sub.w d1,d3
- addq #1,d3
- ext.l d2
- move.l d2,d4
- moveq #0,d5
- btst #30,d2
- beq.b d2notneg
- neg.l d2
- bchg #0,d5
- d2notneg:
- btst #15,d3
- beq.b d3notneg
- neg.w d3
- bchg #0,d5
- d3notneg:
- divs d3,d2 ;remainder in high word.
- move.w d2,d1
- clr.w d2
- divu d3,d2
- swap d1
- move.w d2,d1
- btst #0,d5
- beq.b pos
- neg.l d1
- pos:
- rts
-
- vc_fclk:
- move.l #vc_pfp,vc_ds2+2
- move.l #vc_pfs,vc_ds3+2
- vc_ds3: lea vc_pfs,a5
- vc_ds2: lea vc_pfp,a6 ;find & make clockwise points vc_pfp to vc_pfs
-
- tst.w (a6)
- beq.w vc_es
-
- move.w 2(a6),d0
- move.w 4(a6),d1
- move.w 6(a6),d2
- move.w 8(a6),d3
- move.w 10(a6),d4
- move.w 12(a6),d5
- sub.w d2,d4
- sub.w d3,d5
- sub.w d0,d2
- sub.w d1,d3
- muls d2,d5
- muls d3,d4
- sub.l d4,d5
- bpl.b vc_nok
- add.w #100,vc_ds2+4
- bra.b vc_ds2
-
-
- vc_nok: lea 2(a6),a1
- move.l a1,a0
- move.l (a1)+,d1
- add.w #127,d1
- swap d1
- add.w #160,d1
- vc_nc3: move.l (a1)+,d0
- tst.l d0
- beq.b vc_mkclk
- add.w #127,d0
- swap d0
- add.w #160,d0
- cmp.l d0,d1
- blt.b vc_nc3
- move.l d0,d1
- lea -4(a1),a0
- bra.b vc_nc3
- vc_mkclk:
- lea (a5),a2
- lea (a0),a4
- move.w (a6)+,d6
- lsl.w #2,d6
- addq #4,d6
- neg.w d6
- lea (a2,d6),a3
- sub.w d6,a6 ;a6 contains pointer to last 2 co-ords...
- vc_nc: move.l (a0)+,d0
- add.w #127,d0
- swap d0
- add.w #160,d0
- move.l d0,(a2)+
- move.l d0,(a3)+
- cmp.l a6,a0
- bne.b vc_df
- add.w d6,a0
- vc_df: cmp.l a4,a0
- bne.b vc_nc
- add.w #200,vc_ds3+4 ;sw
- add.w #100,vc_ds2+4
- bra.w vc_ds3
- vc_es: clr.w (a5)
- rts
-
-
- ;---------------
-
- ccop: dc.w diwstrt,$2981
- dc.w diwstop,$29c1
- dc.w ddfstrt,$38
- dc.w ddfstop,$d0
-
- cp_config: dc.w bplcon0,0
- dc.w bplcon1,$0
- dc.w bplcon2,%0
- cp_modulo: dc.w $108,0,$10a,0
-
- cp_sprite: dc.w $120,$0,$122,$0,$124,$0,$126,$0,$128,$0,$12a,$0,$12c
- dc.w $0,$12e,$0,$130,$0,$132,$0,$134,$0,$136,$0,$138,$0
- dc.w $13a,$0,$13c,$0,$13e,$0
- cp_palette:
- dc.w col0,0,col1,$3,col2,$5,col3,$7,col4,$9
- dc.w col5,$b,col6,$d
- dc.w col7,$f,col8,$f0,col9,$c0,col10,$c0,col11,$c0,col12,$c0
- dc.w col13,$c0
- dc.w col14,$c0,col15,$c0,col16,0,col17,0,col18,0,col19,0,col20,0
- dc.w col21,0,col22,0,col23,0,col24,0,col25,0,col26,0,col27,0
- dc.w col28,0,col29,0,col30,0,col31,0
- cp_plns:
- dc.w bpl1pth,0,bpl1ptl,0
- dc.w bpl2pth,0,bpl2ptl,0
- dc.w bpl3pth,0,bpl3ptl,0
- dc.w bpl4pth,0,bpl4ptl,0
-
- cp_bd1: dc.w bplcon0,%0100000000000000
-
- dc.w $7109,$fffe,col8,$af,col9,$af,col10,$af,col11,$af,col12,$af
- dc.w col13,$af,col14,$af,col15,$af
- dc.w $7209,$fffe
-
- cp_plns2: dc.w bpl4pth,0,bpl4ptl,0
- dc.w $ffdf,$fffe
- dc.w intreq,$8010
- dc.w $ffff,$fffe
-
- ccop2: dc.w diwstrt,$2981
- dc.w diwstop,$29c1
- dc.w ddfstrt,$3c
- dc.w ddfstop,$d4
-
- cp2_config: dc.w bplcon0,%1001000000000000
- dc.w bplcon1,$0
- dc.w bplcon2,%0
-
- cp2_modulo: dc.w $108,0,$10a,0
-
- cp2_sprite: dc.w $120,$0,$122,$0,$124,$0,$126,$0,$128,$0,$12a,$0,$12c
- dc.w $0,$12e,$0,$130,$0,$132,$0,$134,$0,$136,$0,$138,$0
- dc.w $13a,$0,$13c,$0,$13e,$0
- cp2_palette:
- dc.w col0,$ccc,col1,$0,col2,$5,col3,$7,col4,$9
- dc.w col5,$b,col6,$d
- dc.w col7,$f,col8,$f0,col9,$c0,col10,$c0,col11,$c0,col12,$c0
- dc.w col13,$c0
- dc.w col14,$c0,col15,$c0,col16,0,col17,0,col18,0,col19,0,col20,0
- dc.w col21,0,col22,0,col23,0,col24,0,col25,0,col26,0,col27,0
- dc.w col28,0,col29,0,col30,0,col31,0
- cp2_plns:
- dc.w bpl1pth,0,bpl1ptl,0
- dc.w bpl2pth,0,bpl2ptl,0
- dc.w bpl3pth,0,bpl3ptl,0
- dc.w bpl4pth,0,bpl4ptl,0
-
- dc.w intreq,$8010
-
- dc.w $ffff,$fffe
-
- pcop: dc.l 0 ;Previous copper address
-
- gfxname: dc.b "graphics.library",0
- even
-
- s_1: dcb.l 2,0
-
- screen: dc.l 0,0
- pl_menu: dc.l 0
- pl_logo: ds.l 10*80
-
- xtheta: dc.w 1
- ytheta: dc.w 1
- ztheta: dc.w 1
- vc_dst: dc.w 256
-
- vc_cr: dcb.w 100,0
-
- vc_faces: dc.w 6-1
- vc_a: dc.l vc_1a,vc_2a,vc_3a,vc_4a,vc_5a,vc_6a,0
- vc_ca: dc.w 0,0,-60,60,0,0,0,0,60,-60,0,0,-60,0,0,60,0,0
- vc_1a: dc.w 3
- dc.w -60,-60,-60,60,-60,-60,60,60,-60,-60,60,-60
- vc_2a: dc.w 3
- dc.w 60,-60,-60,60,-60,60,60,60,60,60,60,-60
- vc_3a: dc.w 3
- dc.w 60,-60,60,-60,-60,60,-60,60,60,60,60,60
- vc_4a: dc.w 3
- dc.w -60,-60,60,-60,-60,-60,-60,60,-60,-60,60,60
- vc_5a: dc.w 3
- dc.w -60,-60,60,60,-60,60,60,-60,-60,-60,-60,-60
- vc_6a: dc.w 3
- dc.w -60,60,-60,60,60,-60,60,60,60,-60,60,60
-
- vc_pfp: dcb.w 200,0
-
- dcb.w 200,0
- vc_pfs: dcb.w 4000,0 ;4k - just to be safe!
-
- vc_lx: dc.l 0
- vc_rx: dc.l 0
-
- menu_on: dc.w -1
-
- shades: incbin "shades.bmp"
- sintable: incbin "sintable.I"
-
-
-